#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc_fop_prop3.info <<'%EOF%'
   cc_fop_prop3
   ------------
   Molecule:         N2 in D2h
   Wave Function:    CCS, MP2, CCSD / aug-cc-pVDZ
   Test Purpose:     First-order one-electron properties
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > cc_fop_prop3.mol <<'%EOF%'
BASIS
aug-cc-pVDZ
first order property calculation on N2
small test-basis
    1    3  X  Y  Z   1.00D-15
        7.0   1    3    1    1    1
N     0.0000000000000000  0.0000000000000000 1.03715750000000000       *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc_fop_prop3.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTIONS
**INTEGRAL
.DIPLEN
.THETA
.EFGCAR
.SECMOM
.DARWIN
.MASSVELO
**WAVE FUNCTION
.CC
*SCF INP
.THRESH
 1.0D-10
.DOUBLY OCCUPIED
 3 1 1 0 2 0 0 0
*CC INP
.CCS
.MP2
.CCSD
.PRINT
 6
.THRENR
1.0D-10
.NSYM
8
.FROIMP
1 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0
.THRLEQ
1.0D-07
*CCFOP
.ALLONE
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc_fop_prop3.check
cat >>cc_fop_prop3.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CCSD energies:
CRIT1=`$GREP "Final * HF energy:" $log | $GREP "\-108.96064996" | wc -l`
CRIT2=`$GREP "Total SCF   energy:                  \-108.96064996" $log | wc -l`
CRIT3=`$GREP "Total MP2   energy:                  \-109.27784304" $log | wc -l`
CRIT4=`$GREP "Total CCSD  energy:                  \-109.28046029" $log | wc -l`
TEST[1]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[1]=10
ERROR[1]="ENERGIES NOT CORRECT"

# RELAXED CCS FOPs:
CRIT1=`$GREP "1 *  ( |0)\.447428.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT2=`$GREP "2 * ( |0)\.00000000 * ( |0)\.447428.. * ( |0)\.00000000" $log | wc -l`
CRIT3=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * ( -|-0)\.894857.." $log | wc -l`
CRIT4=`$GREP "1 * 7\.770461.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l` 
CRIT5=`$GREP "2 * ( |0)\.00000000 * 7\.770461.. * ( |0)\.00000000" $log | wc -l` 
CRIT6=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * 23\.725058.." $log | wc -l` 
CRIT7=`$GREP "Alfa\*\*2 Invariant:  [ ]* 171.313032" $log | wc -l` 
CRIT8=`$GREP "Beta\*\*2 Invariant:  [ ]* 254.549162" $log | wc -l` 
CRIT9=`$GREP "Isotropic Property: [ ]* 13.088660 a.u." $log | wc -l` 
CRIT10=`$GREP "Property anisotropy invariant:  [ ]* 15.954597 a.u." $log | wc -l` 
CRIT11=`$GREP "1 * ( |0)\.559056.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT12=`$GREP "2 * ( |0)\.00000000 * ( |0)\.559056.. * ( |0)\.00000000" $log | wc -l`
CRIT13=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * -1\.118113.." $log | wc -l`
CRIT14=`$GREP " N   _[12] 14    Vx =       ( |0)\.559057     2\.684970     ( |0)\.959175" $log | wc -l`
CRIT15=`$GREP " N   _[12] 14    Vy =       ( |0)\.559057     2\.684970     ( |0)\.959175" $log | wc -l`
CRIT16=`$GREP " N   _[12] 14    Vz =      -1\.118113    -5\.369940    -1\.918350" $log | wc -l`
CRIT17=`$GREP "[1-elec.]* Darwin term: [ ]* ( |0)\.230697" $log | wc -l`
CRIT18=`$GREP "Mass-Velocity term: [ ]*( -|-0)\.288759" $log | wc -l`
CRIT19=`$GREP "(Mass-Velocity \+ 1-elec. Darwin terms|Total relativistic correction):[ ]* ( -|-0)\.058062" $log | wc -l`
TEST[2]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 + $CRIT4 \+ $CRIT5 \+ $CRIT6 + $CRIT7 \+ $CRIT8 \+ $CRIT9 \
 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ $CRIT13 + $CRIT14 \+ $CRIT15 \+ $CRIT16 + $CRIT17 \+ $CRIT18 \
 \+ $CRIT19`
CTRL[2]=25
ERROR[2]="RELAXED CCS FIRST-ORDER PROPERTIES NOT CORRECT"

# RELAXED MP2 FOPs:
CRIT1=`$GREP "1 * ( |0)\.589346.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT2=`$GREP "2 * ( |0)\.00000000 * ( |0)\.589346.. * ( |0)\.00000000" $log | wc -l`
CRIT3=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * -1\.178693.." $log | wc -l`
CRIT4=`$GREP "1 * 7\.737181.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l` 
CRIT5=`$GREP "2 * ( |0)\.00000000 * 7\.737181.. * ( |0)\.00000000" $log | wc -l` 
CRIT6=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * 23\.975614.." $log | wc -l` 
CRIT7=`$GREP "Alfa\*\*2 Invariant:  [ ]* 172.922300" $log | wc -l` 
CRIT8=`$GREP "Beta\*\*2 Invariant:  [ ]* 263.686722" $log | wc -l` 
CRIT9=`$GREP "Isotropic Property: [ ]* 13.149992 a.u." $log | wc -l` 
CRIT10=`$GREP "Property anisotropy invariant:  [ ]* 16.238433 a.u." $log | wc -l` 
CRIT11=`$GREP "1 * ( |0)\.436982.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT12=`$GREP "2 * ( |0)\.00000000 * ( |0)\.436982.. * ( |0)\.00000000" $log | wc -l`
CRIT13=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * ( -|-0)\.873964.." $log | wc -l`
CRIT14=`$GREP " N   _[12] 14    Vx =       ( |0)\.436982     2\.098687     ( |0)\.749732" $log | wc -l`
CRIT15=`$GREP " N   _[12] 14    Vy =       ( |0)\.436982     2\.098687     ( |0)\.749732" $log | wc -l`
CRIT16=`$GREP " N   _[12] 14    Vz =      ( -|-0)\.873965    -4\.197374    -1\.499464" $log | wc -l`
CRIT17=`$GREP "[1-elec.]* Darwin term: [ ]* ( |0)\.230613" $log | wc -l`
CRIT18=`$GREP "Mass-Velocity term: [ ]*( -|-0)\.288752" $log | wc -l`
CRIT19=`$GREP "(Mass-Velocity \+ 1-elec. Darwin terms|Total relativistic correction):[ ]* ( -|-0)\.058138" $log | wc -l`
TEST[3]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 + $CRIT4 \+ $CRIT5 \+ $CRIT6 + $CRIT7 \+ $CRIT8 \+ $CRIT9 \
 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ $CRIT13 + $CRIT14 \+ $CRIT15 \+ $CRIT16 + $CRIT17 \+ $CRIT18 \
 \+ $CRIT19`
CTRL[3]=25
ERROR[3]="RELAXED MP2 FIRST-ORDER PROPERTIES NOT CORRECT"


# RELAXED CCSD FOPs:
CRIT1=`$GREP "1 * ( |0)\.550496.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT2=`$GREP "2 * ( |0)\.00000000 * ( |0)\.550496.. * ( |0)\.00000000" $log | wc -l`
CRIT3=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * -1\.100993.." $log | wc -l`
CRIT4=`$GREP "1 * 7\.750322.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l` 
CRIT5=`$GREP "2 * ( |0)\.00000000 * 7\.750322.. * ( |0)\.00000000" $log | wc -l` 
CRIT6=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * 23\.911055.." $log | wc -l` 
CRIT7=`$GREP "Alfa\*\*2 Invariant:  [ ]* 172.586898" $log | wc -l` 
CRIT8=`$GREP "Beta\*\*2 Invariant:  [ ]* 261.169296" $log | wc -l` 
CRIT9=`$GREP "Isotropic Property: [ ]* 13.137233 a.u." $log | wc -l` 
CRIT10=`$GREP "Property anisotropy invariant:  [ ]* 16.160733 a.u." $log | wc -l` 
CRIT11=`$GREP "1 * ( |0)\.459852.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT12=`$GREP "2 * ( |0)\.00000000 * ( |0)\.459852.. * ( |0)\.00000000" $log | wc -l`
CRIT13=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * ( -|-0)\.919704.." $log | wc -l`
CRIT14=`$GREP " N   _[12] 14    Vx =       ( |0)\.459852     2\.208524     ( |0)\.788970" $log | wc -l`
CRIT15=`$GREP " N   _[12] 14    Vy =       ( |0)\.459852     2\.208524     ( |0)\.788970" $log | wc -l`
CRIT16=`$GREP " N   _[12] 14    Vz =      ( -|-0)\.919705    -4\.417048    -1\.577940" $log | wc -l`
CRIT17=`$GREP "[1-elec.]* Darwin term: [ ]* ( |0)\.230597" $log | wc -l`
CRIT18=`$GREP "Mass-Velocity term: [ ]*( -|-0)\.288707" $log | wc -l`
CRIT19=`$GREP "(Mass-Velocity \+ 1-elec. Darwin terms|Total relativistic correction):[ ]* ( -|-0)\.058110" $log | wc -l`
TEST[4]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 + $CRIT4 \+ $CRIT5 \+ $CRIT6 + $CRIT7 \+ $CRIT8 \+ $CRIT9 \
 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ $CRIT13 + $CRIT14 \+ $CRIT15 \+ $CRIT16 + $CRIT17 \+ $CRIT18 \
 \+ $CRIT19`
CTRL[4]=25
ERROR[4]="RELAXED CCSD FIRST-ORDER PROPERTIES NOT CORRECT"


PASSED=1
for i in 1 2 3 4 
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%
#######################################################################
